﻿Public Class frmSuaHoSoGiaoVien

    Public MaGV As Integer
    Public MaMon As Integer = -1

    

    Private Sub frmSuaHoSoGiaoVien_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New List(Of MonHocDTO)
        Dim hsBUS As New MonHocBUS()
        ds = MonHocBUS.SelectAll()

        cboMon.DataSource = ds
        cboMon.ValueMember = "MAMON"
        cboMon.DisplayMember = "TENMON"

        If MaMon > -1 Then
            cboMon.SelectedValue = MaMon
        End If
    End Sub

    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        Dim gvDTO As New GiaoVienDTO()
        gvDTO.MAGIAOVIEN = MaGV
        gvDTO.TENGIAOVIEN = txtTenGV.Text
        If (rbNam.Checked) Then
            gvDTO.GIOITINH = "Nam"
        Else
            gvDTO.GIOITINH = "Nữ"
        End If
        gvDTO.NGAYSINH = txtNgaySinh.Text
        'hsDTO.cmnd = txtCMND.Text
        'hsDTO.NGAYSINH = dtpNgaySinh.Value
        gvDTO.DIACHI = txtDiaChi.Text
        gvDTO.SODT = txtSoDT.Text
        gvDTO.EMAIL = txtEmail.Text
        gvDTO.MAMON = cboMon.SelectedValue

        Dim gvBUS As New GiaoVienBUS()
        Dim res = GiaoVienBUS.SuaGiaoVien(gvDTO)
        If res >= 0 Then
            MessageBox.Show("Sửa thành công")
        Else
            MessageBox.Show("Sửa thất bại")
        End If
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtMaGV.Text = String.Empty
        txtTenGV.Text = String.Empty
        rbNam.Checked = True
        txtNgaySinh.Text = String.Empty
        txtDiaChi.Text = String.Empty
        txtEmail.Text = String.Empty
        txtSoDT.Text = String.Empty
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class